package com.itheima.dao;

import com.github.pagehelper.Page;
import com.itheima.pojo.Order;
import com.itheima.pojo.OrderUpdateRequestBody;
import com.itheima.pojo.SubmitOrder;
import org.apache.ibatis.annotations.Insert;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Select;

import java.util.Date;

@Mapper
public interface OrderMapper {
    /**
     * 分页查询预约信息
     * @param queryString
     * @return
     */
    Page<Order> findPage(String queryString);
    // Page<OrderFindPageResult> findPage(String queryString);

    /**
     * 修改预约信息
     * @param orderUpdateRequestBody
     */
    void update(OrderUpdateRequestBody orderUpdateRequestBody);

    /**
     * 根据id查询预约信息
     * @param id
     * @return
     */
    @Select("select * from itcast_health.t_order where id = #{id}")
    Order findById(Integer id);

    @Select("select count(id) from itcast_health.t_order where orderDate = #{orderDate}")
    Integer findCountByOrderDate(Date orderDate);

    @Insert("insert into itcast_health.t_ordersubmit(idCard, name, orderDate, setmealId, sex, telephone, validateCode) value" +
            "(#{idCard},#{name},#{orderDate},#{setmealId},#{sex},#{telephone},#{validateCode})")
    void add(SubmitOrder submitOrder);
}
